import Vue from 'vue'

// 权限检查方法
Vue.prototype.$_has = function (value) {
 let btnPermissions_arr = sessionStorage.getItem("btnPermissions");
 let btnPermissionsStr = JSON.parse(btnPermissions_arr).data;
 if (btnPermissionsStr == undefined || btnPermissionsStr == null) {
  return false;
 }
 for(let i = 0;i<btnPermissionsStr.length;i++){
     if(value == btnPermissionsStr[i]){
         return true
     }
 }
 return false;
};
/**权限指令**/
const has = Vue.directive('has', {
    inserted: function (el, binding, vnode) {
        let btnPermissions_json = binding.value.mate
        if (!Vue.prototype.$_has(btnPermissions_json)) {
           el.parentNode.removeChild(el);
        }
    },
});

export {has}
